package com.wuwangfu.stream;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author jcshen
 * @Date 2023-02-21
 * @PackageName:com.wuwangfu.stream
 * @ClassName: DFromCollection
 * @Description: TODO
 * @Version 1.0
 *
 * fromCollection创建的DataStream的并行度为1，是一个有限的数据流，程序执行完退出，通常测试使用
 *
 */
public class DFromElement {

    public static void main(String[] args) throws Exception {

        Configuration config = new Configuration();
        //设置web ui端口
        config.setInteger("rest.port",8181);

        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(config);

        DataStreamSource<Integer> nums = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8, 9);
        int paralle = nums.getParallelism();
        System.err.println(paralle);

        nums.print();
        env.execute("from element");

    }
}
